package org.linlinjava.litemall.admin.web;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.service.PiccArticlesService;
import org.linlinjava.litemall.db.service.PiccMeasureService;
import org.linlinjava.litemall.db.service.PiccMessagePackageService;
import org.linlinjava.litemall.db.service.PiccPatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin/piccboard")
@Validated
public class PiccDashbordController {
    @Autowired
    PiccPatientService patientService;
    @Autowired
    PiccMeasureService measureService;
    @Autowired
    PiccMessagePackageService messagePackageService;
    @Autowired
    PiccArticlesService articlesService;

    @GetMapping("")
    public Object info(@RequestParam(defaultValue = "0") Integer nurseId) {
        int userTotal = patientService.count(nurseId);
        int goodsTotal = measureService.count(nurseId);
        int productTotal = messagePackageService.count(nurseId);
        int orderTotal = articlesService.count();
        Map<String, Integer> data = new HashMap<>();
        data.put("userTotal", userTotal);
        data.put("goodsTotal", goodsTotal);
        data.put("productTotal", productTotal);
        data.put("orderTotal", orderTotal);

        return ResponseUtil.ok(data);
    }
}
